package com.itheima.Jiuye09;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class MapTest02 {
    public static void main(String[] args) {
        Map<String,String> mp = new HashMap<>();
        mp.put("王五","小花");
        mp.put("赵六","小翠");
        mp.put("李四","小芳");
        mp.put("老孙","翠花");
        Set<Map.Entry<String, String>> entries = mp.entrySet();
        for (Map.Entry<String, String> entry : entries) {

            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+"-"+value);
        }
        System.out.println("-----------");
        Iterator<Map.Entry<String, String>> iterator = entries.iterator();
        while (iterator.hasNext()){
            Map.Entry<String, String> entry = iterator.next();
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+"-"+value);
        }
    }
}
